package com.buddy.hadoop.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

import java.io.IOException;

public class FileSystemCat {
    public static void main(String[] args) throws IOException {
        Configuration conf = new Configuration();
        Path fpath = new Path(args[0]);
        FileSystem hdfs = FileSystem.get(conf);
        FSDataInputStream inputStream = null;
        try {
            inputStream = hdfs.open(fpath);
            IOUtils.copyBytes(inputStream, System.out, 4096, false);
        } finally {
            IOUtils.closeStream(inputStream);
        }
    }
}
